// .txt

beginzonescript;

variables;

short crime_tolerance = 5;
short last_abil;
short i;
short spawn_count = 0;

body;

beginstate INIT_STATE;
	if (gf(41,3) > 0)
		sf(45,16,1);
		
	set_name(8,"Commander Beloy");
	set_level(8,25);
	set_boss_level(8,1);
	set_name(9,"Captain Addison");
	set_boss_level(9,1);
	if (gf(39,4) == 1)
		erase_char(9);
	if (gf(45,1) > 0)
		erase_char(9);
		
	set_name(10,"Construction Servile");
	set_name(11,"Construction Servile");
	set_name(12,"Construction Servile");
	set_name(13,"Construction Servile");
	set_name(14,"Construction Servile");
	set_name(15,"Construction Servile");
	set_name(16,"Captain Zoka");
	set_name(17,"Shaper Alexie");
	
	set_aggression(33,9);
	set_aggression(34,9);
	set_aggression(35,9);
	
	if (gf(45,13) > 0)
		sf(45,5,1);
	sf(45,13,0);
	
//	add_range_to_group(first,last,whichg);

	if (gf(100,11) > 0) {
		print_str_color("Word of your infamy has gotten here before you. You are forever marked",3);
		print_str_color("  as a foe of the Shapers.",3);
		sf(45,5,1);
		}
	if (get_sdf(45,5) > 0) {
		make_zone_hostile();
		}
		else {
			print_str_color("This is a friendly fort. You are able to rest.",2);
			revive_party();
			}	

	last_abil = get_current_tick();
	
	set_crime_tolerance(crime_tolerance);
	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
	// clear zone?
	//if ((zone_clear(ME) == FALSE) && (get_flag(,) > 0)) {
		//print_str_color("",2);
		//clear_zone(ME);	
		//}
		
	if ((get_crime_level() >= crime_tolerance) && (get_sdf(45,5) == 0)) {
		make_zone_hostile();
		set_flag(45,5,1);
		}

	if (gf(45,5) == 0) {
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(8,"Must check the watch.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(8,"Need more creations.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(8,"Why are you here?");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(8,"You should move on.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16,"Get those bricks.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16,"Don't put that there!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16,"Move that west.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16,"Move that east.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16,"Is anyone listening?");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17,"How interesting.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17,"Fascinating.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17,"Your skin!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17,"What unusual eyes.");

		}

	if ((char_ok(9)) && (get_attitude(9) >= 10) && (gf(45,5) == 0) && (dist_to_nav_point(9,0) <= 6)) {
		print_named_str(9,"leaves the office and shouts an alarm.");
		sf(45,5,1);
		make_zone_hostile();
		begin_talk_mode(9);		
		}
	if ((char_ok(10)) && (get_attitude(10) >= 10) && (gf(45,5) == 0) && (dist_to_nav_point(10,0) <= 6)) {
		print_named_str(10,"leaves the office and shouts an alarm.");
		sf(45,5,1);
		make_zone_hostile();
		begin_talk_mode(10);		
		}
	
	if (((is_combat()) && (tick_difference(last_abil,get_current_tick()) > 0)) || ((is_group()) && (tick_difference(last_abil,get_current_tick()) > 5))) {
		last_abil = get_current_tick();
		
		if ((num_chars_in_group(1) == 0) && (party_dist_to_nav(7) > 10)) {
			spawn_count = spawn_count + 1;
			if (spawn_count == 5) {
				spawn_count = 0;
				print_str_color("You hear howling and snarling. It comes from outside the east gate.",2);
				i = get_ran(1,0,2);
				if (i == 0) {
					spawn_creature(28);
					spawn_creature(29);
					spawn_creature(30);
					set_boss_level(36,1);
					set_boss_level(37,1);
					set_boss_level(38,1);
					}
				if (i == 1) {
					spawn_creature(31);
					spawn_creature(32);
					spawn_creature(33);
					set_boss_level(39,1);
					set_boss_level(40,1);
					set_boss_level(41,1);
					}
				if (i == 2) {
					spawn_creature(34);
					spawn_creature(35);
					spawn_creature(36);
					set_boss_level(42,1);
					set_boss_level(43,1);
					set_boss_level(44,1);
					}
				}
			}
		
		if ((gf(45,13) > 0) && (gf(45,13) < 11) && (gf(45,5) == 0)) {
			inc_flag(45,13,1);

			if (gf(45,13) == 11) {
				sf(45,5,1);
				make_zone_hostile();
				begin_talk_mode(9);
				}
			}
		}
		
break;

//beginstate 10;
//break;

//	print_str("");
//	set_terrain_string_range(".",3);
//	set_terrain_string_range("The sign says - .",3);
